package com.databias.j15.examples;

import java.awt.Font;
import java.util.Random;

import com.databias.j15.GHistogram;
import com.databias.j15.GText;
import com.databias.j15.GScreen;

import com.databias.j15.G15DebugScreen;

public class HistogramExample {
	
	static boolean stop = false;
	static int screenNum =0;
	
	public void start ()
	{
		
		// Create the G15 container
		GScreen panelscreen= new GScreen();
		
		// Make our container 
		// 10 segments, height of 20
		GHistogram gh=new GHistogram(10, 30, 50, 20);
		
		// JFrame for debugging
		G15DebugScreen frame= new G15DebugScreen("Histogram Example", panelscreen);
		

		// Put them on the screen
		panelscreen.add(15,8, new GText("Histogram", new Font ("Dialog", Font.PLAIN, 10)));
		panelscreen.add(20, 68, gh);
		
		Random r = new Random();
		
		
		// Main loop
		while (!stop)
		{
			// Ask the components for an update
			gh.add(r.nextInt(101));

			// Have the collections update their attached Graphics
			panelscreen.draw();

			frame.repaint();
			
			// Wait and do it again
			try {
				Thread.sleep(300);
			} catch (InterruptedException e) {
				stop=true;
				e.printStackTrace();
			}


		}  // Main loop
		
	}
	

	public static void main(String[] args) 
	{
		HistogramExample h= new HistogramExample();
		h.start();
		
	}
}



